/**      
 * @file		stringFun.cpp
 * @description	This example demonstrates how we can use
 *				string objects and their some of their member
 *				functions. You should experiment with all the
 *				samples.
 * @course		CSCI 123 Section 00000
 * @assignment 
 * @date		mm/dd/yyyy
 * @author		Brad Rippe (00000000) brippe@fullcoll.edu
 * @version		1.0
 */
#include <iostream>
#include <string>
using namespace std;

/**
 * @return zero if the application executes successfully
 */
int main() {
	string string1 = "I'm looking for csci 123 in this string. ";
	string string2 = "Swapping strings";

	int foundAt = string1.find("csci 123");
	cout << "Searching in '" << string1 << "'\n";
	if(foundAt >= 0) {
		cout << "Found 'csci 123' at position ";
		cout << foundAt << endl;
	} else {
		cout << "Didn't find 'csci 123' in string1\n";
	}

	cout << "Character at " << foundAt << " is " << string1.at(foundAt) 
	     << endl;
	cout << "Using substr to output \"csci 123\"\n";
	cout << string1.substr(foundAt, 8) << endl;
	
	string1.append("Programming like a rock star now!");
	cout << "Appending more text to string1\n";
	cout << string1 << endl;

	string1.erase(foundAt, 9);
	cout << "Removing text from the string. What do you think I removed?\n";
	cout << string1 << endl;

	// this is the coolest string function
	cout << "string1 = " << string1 << endl;
	cout << "string2 = " << string2 << endl;
	string1.swap(string2);
	cout << "Swap()\n";
	cout << "string1 = " << string1 << endl;
	cout << "string2 = " << string2 << endl;
	return 0;
}

